function getWaDOMMethod() {
    if ("" == ContactClass && getContactClass(), waElMethod = "", document.getElementsByClassName(ContactClass).length > 0)
        for (var a in document.getElementsByClassName(ContactClass)[0]) "__" == a.substr(0, 2) && (waElMethod = a);
    else {
        var b = document.querySelectorAll(".chatlist-panel-body .chat-drag-cover");
        if (b.length > 0)
            for (var a in b[0].parentElement) "__" == a.substr(0, 2) && (waElMethod = a)
    }
    return waElMethod
}

function getWaMyNum() {
    return waMyNum = "",
        "object" == typeof Store && "object" == typeof Store.Conn && "string" == typeof Store.Conn.me && (waMyNum = Store.Conn.me),
        waMyNum
}

function getWebpackFunctionID(a) {
    for (i = 0; i < 1e4; i++) try {
        if (webpackJsonp([], null, [i]) && webpackJsonp([], null, [i])[a] && "function" == typeof webpackJsonp([], null, [i])[a]) return i
    } catch (b) {}
    return !1
}

function getUserInfoID() {
    return UserInfoId = getWebpackFunctionID("formattedUser"), !!UserInfoId || (UserInfoId = 0, !1)
}

function getContactClass() {
    ContactClass = [];
    for (i = 15e3; i < 2e4; i++) try {
        webpackJsonp([], null, [i]) && webpackJsonp([], null, [i]).avatar && ContactClass.push(webpackJsonp([], null, [i]).avatar)
    } catch (a) {}
}

function getWelcomeClass() {
    for (i = 15e3; i < 2e4; i++) try {
        if (webpackJsonp([], null, [i]) && webpackJsonp([], null, [i]).secondaryText && webpackJsonp([], null, [i]).intro) return void(WelcomeClass = webpackJsonp([], null, [i]).secondaryText)
    } catch (a) {}
}

function getContactExistence(a, b) {
    var c = webpackJsonp([], null, [UserInfoId]).numberToWid(a);
    return 0 != queryExistId && queryExistId || (queryExistId = getWebpackFunctionID("queryExist")),
        queryExistId ? void webpackJsonp([], null, [queryExistId]).queryExist(c).then(function(c) {
            var d = !1;
            200 === c.status && (d = !0),
                "undefined" != typeof b ? wdIay("idexistsdone", {
                    exists: d,
                    tabid: b,
                    id: a
                }) : wdIay("idexistsdone", {
                    exists: d,
                    id: a
                })
        }) : (queryExistId = 0, !1)
}

function SendIfIsValidContact(a, b) {
    if (0 != UserInfoId && UserInfoId || getUserInfoID(), UserInfoId > 0) {
        if (0 != queryExistId && queryExistId || (queryExistId = getWebpackFunctionID("queryExist")), !queryExistId) return queryExistId = 0, !1;
        webpackJsonp([], null, [queryExistId]).queryExist(a).then(function(c) {
            var d = !1;
            if (200 === c.status) {
                d = !0,
                    Store.Chat.gadd(a);
                var e = Store.Chat.get(a);
                "undefined" != typeof e && e.sendMessage(b)
            }
        })
    }
    return !1
}

function getContactBlockClass() {
    for (ContactBlockClass = {},
        i = 15e3; i < 2e4; i++) try {
        if (webpackJsonp([], null, [i]) && webpackJsonp([], null, [i]).container && webpackJsonp([], null, [i]).title && webpackJsonp([], null, [i]).animate) return ContactBlockClass.container = webpackJsonp([], null, [i]).container,
            ContactBlockClass.title = webpackJsonp([], null, [i]).title, !0
    } catch (a) {}
    return !1
}

function getPanesBlockClass() {
    for (PanesBlockClass = {},
        i = 15e3; i < 2e4; i++) try {
        if (webpackJsonp([], null, [i]) && webpackJsonp([], null, [i]).app && webpackJsonp([], null, [i]).app && webpackJsonp([], null, [i]).pane && webpackJsonp([], null, [i]).paneOne && webpackJsonp([], null, [i]).paneTwo && webpackJsonp([], null, [i]).paneThree && webpackJsonp([], null, [i]).drawerManager) return PanesBlockClass.app = webpackJsonp([], null, [i]).app,
            PanesBlockClass.pane = webpackJsonp([], null, [i]).pane,
            PanesBlockClass["pane-one"] = webpackJsonp([], null, [i]).paneOne,
            PanesBlockClass["pane-two"] = webpackJsonp([], null, [i]).paneTwo,
            PanesBlockClass["pane-three"] = webpackJsonp([], null, [i]).paneThree,
            PanesBlockClass["drawer-manager"] = webpackJsonp([], null, [i]).drawerManager, !0
    } catch (a) {}
    return !1
}

function getMainTrigger() {
    MainTriggerId = 0,
        0 != MainTriggerId && MainTriggerId || (MainTriggerId = getWebpackFunctionID("openChatAt"))
}
var StoreChatOld = "",
    WaDOMMethod = "",
    WaMyNum = "",
    UserInfoId = 0,
    ContactClass = [],
    ContactBlockClass = {},
    PanesClass = [],
    PanesBlockClass = {},
    WelcomeClass = "",
    queryExistId = 0,
    MainTriggerId = 0,
    isWAStarting = function() {
        return !(document.getElementById("app") && !document.getElementById("startup") && !document.getElementById("initial_startup") && 0 == document.getElementsByClassName("media-body").length)
    },
    wdIay = function(a, b) {
        "undefined" == typeof b && (b = {}),
            b.op = a;
        var c = new CustomEvent("wdIay", {
            bubbles: !0,
            cancelable: !1,
            detail: b
        });
        document.dispatchEvent(c)
    };
document.addEventListener("wdlmk",
        function(a) {
            if ("welcometxt" == a.detail.op) "" == WelcomeClass && getWelcomeClass(),
                "" !== WelcomeClass && wdIay("welcomedone", {
                    "class": WelcomeClass
                });
            else if ("whoIam" == a.detail.op) "" == WaMyNum && getWaMyNum(),
                "" !== WaMyNum && wdIay("knowWhoIam", {
                    me: WaMyNum
                });
            else if ("idexists" == a.detail.op) 0 != UserInfoId && UserInfoId || getUserInfoID(),
                UserInfoId > 0 && getContactExistence(a.detail.id, a.detail.tabid);
            else if ("detailblockclass" == a.detail.op) 0 === Object.keys(ContactBlockClass).length && ContactBlockClass.constructor === Object ? getContactBlockClass() && wdIay("gotDetailBlockClass", {
                container: ContactBlockClass.container,
                title: ContactBlockClass.title
            }) : wdIay("gotDetailBlockClass", {
                container: ContactBlockClass.container,
                title: ContactBlockClass.title
            });
            else if ("panesblockclass" == a.detail.op) 0 === Object.keys(PanesBlockClass).length && PanesBlockClass.constructor === Object ? getPanesBlockClass() && wdIay("gotPanesBlockClass", {
                app: PanesBlockClass.app,
                pane: PanesBlockClass.pane,
                paneone: PanesBlockClass["pane-one"],
                panetwo: PanesBlockClass["pane-two"],
                panethree: PanesBlockClass["pane-three"],
                drawermanager: PanesBlockClass["drawer-manager"]
            }) : wdIay("gotPanesBlockClass", {
                app: PanesBlockClass.app,
                pane: PanesBlockClass.pane,
                paneone: PanesBlockClass["pane-one"],
                panetwo: PanesBlockClass["pane-two"],
                panethree: PanesBlockClass["pane-three"],
                drawermanager: PanesBlockClass["drawer-manager"]
            });
            else if ("getfilteredcontactsinfo" == a.detail.op) {
                var b = a.detail.contacts,
                    c = !1;
                "undefined" != typeof a.detail.dontsendback && (c = a.detail.dontsendback);
                for (var d in b) {
                    var e = "data:image/svg+xml;base64, PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMTIgMjEyIiB3aWR0aD0iMjEyIiBoZWlnaHQ9IjIxMiI+PHBhdGggZmlsbD0iI0RGRTVFNyIgZD0iTTEwNi4yNTEuNUMxNjQuNjUzLjUgMjEyIDQ3Ljg0NiAyMTIgMTA2LjI1UzE2NC42NTMgMjEyIDEwNi4yNSAyMTJDNDcuODQ2IDIxMiAuNSAxNjQuNjU0LjUgMTA2LjI1UzQ3Ljg0Ni41IDEwNi4yNTEuNXoiPjwvcGF0aD48ZyBmaWxsPSIjRkZGIj48cGF0aCBkPSJNMTczLjU2MSAxNzEuNjE1YTYyLjc2NyA2Mi43NjcgMCAwIDAtMi4wNjUtMi45NTUgNjcuNyA2Ny43IDAgMCAwLTIuNjA4LTMuMjk5IDcwLjExMiA3MC4xMTIgMCAwIDAtMy4xODQtMy41MjcgNzEuMDk3IDcxLjA5NyAwIDAgMC01LjkyNC01LjQ3IDcyLjQ1OCA3Mi40NTggMCAwIDAtMTAuMjA0LTcuMDI2IDc1LjIgNzUuMiAwIDAgMC01Ljk4LTMuMDU1Yy0uMDYyLS4wMjgtLjExOC0uMDU5LS4xOC0uMDg3LTkuNzkyLTQuNDQtMjIuMTA2LTcuNTI5LTM3LjQxNi03LjUyOXMtMjcuNjI0IDMuMDg5LTM3LjQxNiA3LjUyOWMtLj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hMzguNzM0IDM4LjczNCAwIDAgMC0xLjIxNS01LjQ5NCAzNi42OCAzNi42OCAwIDAgMC0zLjY0OC04LjI5OCAzNS45MjMgMzUuOTIzIDAgMCAwLTkuNDg5LTEwLjQ4IDM2LjM0NyAzNi4zNDcgMCAwIDAtNi4xNS0zLjY3IDM3LjEyNCAzNy4xMjQgMCAwIDAtNS4xMi0xLjk1OCAzNy42NyAzNy42NyAwIDAgMC0zLjYyNC0uODk2IDM5Ljg3NSAzOS44NzUgMCAwIDAtNy42OC0uNzM3Yy0yMS4xNjIgMC0zNy4zNDUgMTYuMTgzLTM3LjM0NSAzNy4zNDUgMCAyMS4xNTkgMTYuMTgzIDM3LjM0MiAzNy4zNDUgMzcuMzQyeiI+PC9wYXRoPjwvZz48L3N2Zz4=",
                        f = "",
                        g = "",
                        h = "",
                        j = Store.Chat.find(d)._value;
                    if ("undefined" != typeof j && "undefined" != typeof j.contact) switch ("string" == typeof j.contact.attributes.profilePicThumb.eurl && (e = j.contact.attributes.profilePicThumb.eurl), "string" == typeof j.contact.formattedUser && (f = j.contact.formattedUser), "undefined" != typeof j.previewMessage && "string" == typeof j.previewMessage.type && (h = j.previewMessage.type), h) {
                        case "chat":
                            g = j.previewMessage.body;
                            break;
                        default:
                            g = h
                    }
                    b[d] = {
                        picture: e,
                        name: f,
                        msg: g,
                        msgtype: h
                    }
                }
                c || wdIay("gotFilteredData", {
                    contacts: b
                })
            } else if ("openchatat" == a.detail.op)
                if (0 != MainTriggerId && MainTriggerId || getMainTrigger(), "string" == typeof a.detail.msg && "" !== a.detail.msg) {
                    var k = a.detail.id.split(","),
                        l = k.length;
                    for (l >= 25 && (l = 25), i = 0; i < l; i++) {
                        var m = k[i] + "@c.us";
                        m = m.replace("+", "");
                        var n = Store.Chat.get(m);
                        "undefined" != typeof n ? n.sendMessage(a.detail.msg) : SendIfIsValidContact(m, a.detail.msg)
                    }
                    wdIay("endMessageSend", {
                        contacts: b
                    })
                } else MainTriggerId > 0 && webpackJsonp([], null, [MainTriggerId]).openChatAt(Store.Chat.get(a.detail.id));
            else "chatContacts" == a.detail.op && Store.Chat.find(a.detail.waid).then(function(a) {
                var b = [];
                a.isGroup ? (b = a.groupMetadata.participants.models.map(function(a) {
                    return a.id
                }), b.length > 0 && wdIay("insertContactsList", {
                    contacts: b
                })) : (b.push(a.id), b.length > 0 && wdIay("insertContactsList", {
                    contacts: b
                }))
            })
        }),
    window.setInterval(function() {
            if (!isWAStarting()) {
                "" == WaDOMMethod && (WaDOMMethod = getWaDOMMethod()),
                    "" == WaMyNum && (WaMyNum = getWaMyNum(), "" !== WaMyNum && (localStorage.waMyNum = WaMyNum)),
                    0 == ContactClass.length && getContactClass();
                var a = [];
                for (i = 0; i < ContactClass.length; i++) document.getElementsByClassName(ContactClass[i]).length > 0 && (a = document.getElementsByClassName(ContactClass[i]));
                if (a.length > 0) {
                    document.getElementById("wdcolorpanel") || wdIay("needcolorpanel"),
                        a = a[0],
                        a.className.indexOf("well-chat") == -1 && (a.className += " well-chat");
                    var b = a[WaDOMMethod]._currentElement._owner._currentElement.props.contact.id;
                    if (a.setAttribute("waContactID", b), a.hasAttribute("setpin")) {
                        var c = "true" == a.getAttribute("setpin");
                        Store.Chat.get(b).setPin(c),
                            a.removeAttribute("setpin")
                    }
                    var d = a.parentElement.querySelectorAll("span .emojitext");
                    if (d.length > 0)
                        if (d[0].style.display = "block", d[0].style.overflow = "hidden", d[0].style.textOverflow = "ellipsis", d[0].style.whiteSpace = "nowrap", d[0].className.indexOf("selectable-text") == -1 && (d[0].className += " selectable-text copyable-text"), d[0].innerHTML.indexOf("+") < 0 && 0 == d[0].querySelectorAll(".wdNumber").length) {
                            if (UserInfoId > 0 || getUserInfoID()) {
                                var e = "";
                                "undefined" != typeof Store.Chat.get(b).contact.notifyName && (e = Store.Chat.get(b).contact.notifyName),
                                    d[0].innerHTML += "<br/><span class='wdName' style='display:none;'>" + e + "</span><span class='wdNumber'>" + webpackJsonp([], null, [UserInfoId]).formattedUser(b) + "</span>"
                            }
                        } else if (0 == d[0].querySelectorAll(".wdName").length) {
                        var f = "";
                        (UserInfoId > 0 || getUserInfoID()) && (f = webpackJsonp([], null, [UserInfoId]).formattedUser(b));
                        var e = "";
                        "undefined" != typeof Store.Chat.get(b).contact.notifyName && (e = Store.Chat.get(b).contact.notifyName),
                            d[0].innerHTML = "<span class='wdName'>" + e + "</span><br/><span class='wdNumber' style='display:none;'>" + f + "</span>" + d[0].innerHTML
                    }
                }
            }
        },
        500),
    window.setInterval(function() {
            // 1月13日解决whatsapp版本升级问题
            // if (!isWAStarting()) {
            //     var a = document.querySelectorAll(".chatlist-panel-body .chat-drag-cover"),
            //     b = !1;
            //     if ("" == WaDOMMethod && (WaDOMMethod = getWaDOMMethod()), a.length > 0) for (i = 0; i < a.length; i++) if ("undefined" != typeof a[i].parentElement[WaDOMMethod]) {
            //         var c = a[i].parentElement[WaDOMMethod]._currentElement._owner._currentElement.props.dataKey;
            //         "undefined" == typeof c && (c = a[i].parentElement[WaDOMMethod]._currentElement._owner._currentElement.key),
            //         a[i].parentElement.getAttribute("wacontactid") !== c && (a[i].parentElement.setAttribute("wacontactid", c), a[i].parentElement.setAttribute("wastate", "pending"), b = !0)
            //     }
            //     b && wdIay("refreshcontacts")
            // }
        },
        1e3);